package com.cn.crmsystem.controller.censusController;

import com.cn.crmsystem.pojo.Login;
import com.cn.crmsystem.pojo.ResultJson;
import com.cn.crmsystem.pojo.User;
import com.cn.crmsystem.service.censusService.MoneyCensusService;
import com.cn.crmsystem.service.censusService.SalesKitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
//from ldk
@Controller
@Api(value = "仪表盘：1.柱状图的数据" +
        "2.转盘图的数据" +
        "3.排行榜",tags = "仪表盘合同金额目标及完成情况和业绩指标完成率和排行榜的三个模块的接口Api")
public class MoneyCensusController {
    @Autowired
    private MoneyCensusService moneyCensusService;
    @Autowired
    private  SalesKitService salesKitService;



    //合同金额目标及完成情况
    @RequestMapping(value = "/selectMoneyCensus" ,method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "合同金额目标及完成情况的柱状图",notes = "展示的是合同金额的数据",
            httpMethod = "GET",
            response =ResultJson.class )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firstSelect",value = "第二个下拉框的选项：传给后端的值，写四个：nowDay,nowMonth,nowYear,2020-09-07--2020-09-08 默认值为nowDay",
                    paramType = "query",
                    dataType = "String",required =false),
            @ApiImplicitParam(name = "secondSelect",value = "第一个下拉框的选项，传给后端的值，三个：myself,myDepartment,all，默认值：myself",paramType = "query",
                    dataType = "String",required = false),
    })
    public ResultJson moneyCensus( String firstSelect, String secondSelect){
        Login login  = (Login) SecurityUtils.getSubject().getPrincipal(); //接收user类的所有属性
        Integer user_id=login.getUser_id();
        User  user=salesKitService.selectUser(user_id);
      return   moneyCensusService.moneyCensus(user,firstSelect,secondSelect);
    }

    //回款金额
     @RequestMapping(value = "/returnMoneyCensus" ,method = RequestMethod.GET)
     @ResponseBody
     @ApiOperation(value = "回款金额目标及完成情况的柱状图",notes = "都展示的是回款金额的数据",
             httpMethod = "GET",
             response =ResultJson.class )
     @ApiImplicitParams({
             @ApiImplicitParam(name = "firstSelect",value = "第二个下拉框的选项：传给后端的值，写四个：nowDay,nowMonth,nowYear,2020-09-07--2020-09-08 默认值为nowDay",
                     paramType = "query",
                     dataType = "String",required =false),
             @ApiImplicitParam(name = "secondSelect",value = "第一个下拉框的选项，传给后端的值，三个：myself,myDepartment,all，默认值：myself",paramType = "query",
                     dataType = "String",required = false),
     })
    public ResultJson returnMoneyCensus(String firstSelect,String secondSelect){
         Login login  = (Login) SecurityUtils.getSubject().getPrincipal(); //接收user类的所有属性
         Integer user_id=login.getUser_id();
         User  user=salesKitService.selectUser(user_id);
        return moneyCensusService.returnMoneyCensus(user,firstSelect,secondSelect);
    }




    //饼状图
    //合同金额目标及完成情况
    @RequestMapping(value = "/selectMoneyCensusRotating" ,method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "合同金额业绩指标完成率的转盘",notes = "展示的是合同金额的转盘数据，定金和合同金额",
            httpMethod = "GET",
            response =ResultJson.class )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firstSelect",value = "第二个下拉框的选项：传给后端的值，写四个：nowDay,nowMonth,nowYear,2020-09-07--2020-09-08 默认值为nowDay",
                    paramType = "query",
                    dataType = "String",required =false),
            @ApiImplicitParam(name = "secondSelect",value = "第一个下拉框的选项，传给后端的值，三个：myself,myDepartment,all，默认值：myself",paramType = "query",
                    dataType = "String",required = false),
    })
    public ResultJson selectMoneyCensusRotating( String firstSelect, String secondSelect){
        Login login  = (Login) SecurityUtils.getSubject().getPrincipal(); //接收user类的所有属性
        Integer user_id=login.getUser_id();
        User  user=salesKitService.selectUser(user_id);
        return   moneyCensusService.selectMoneyCensusRotating(user,firstSelect,secondSelect);
    }

    //饼状图
    //回款金额
    @RequestMapping(value = "/returnMoneyCensusRotating" ,method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "回款金额业绩指标完成率的转盘",notes = "都展示的是回款金额的数据，尾款和实际金额",
            httpMethod = "GET",
            response =ResultJson.class )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firstSelect",value = "第二个下拉框的选项：传给后端的值，写四个：nowDay,nowMonth,nowYear,2020-09-07--2020-09-08 默认值为nowDay",
                    paramType = "query",
                    dataType = "String",required =false),
            @ApiImplicitParam(name = "secondSelect",value = "第一个下拉框的选项，传给后端的值，三个：myself,myDepartment,all，默认值：myself",paramType = "query",
                    dataType = "String",required = false),
    })
    public ResultJson returnMoneyCensusRotating(String firstSelect,String secondSelect){
        Login login  = (Login) SecurityUtils.getSubject().getPrincipal(); //接收user类的所有属性
        Integer user_id=login.getUser_id();
        User  user=salesKitService.selectUser(user_id);
        return moneyCensusService.returnMoneyCensusRotating(user,firstSelect,secondSelect);
    }



    //  排行榜
    @RequestMapping(value = "/rankingReturnMoney" ,method = RequestMethod.GET)
    @ResponseBody
    //回款排行
    @ApiOperation(value = "排行榜的数据",notes = "回款金额的排行榜",
            httpMethod = "GET",
            response =ResultJson.class )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firstSelect",value = "第二个下拉框的选项：传给后端的值，写四个：nowDay,nowMonth,nowYear,2020-09-07--2020-09-08 默认值为nowDay",
                    paramType = "query",
                    dataType = "String",required =false),
            @ApiImplicitParam(name = "secondSelect",value = "第一个下拉框的选项，传给后端的值，三个：myself,myDepartment,all，默认值：myself",paramType = "query",
                    dataType = "String",required = false),
    })
    public ResultJson rankingReturnMoney( String firstSelect,String secondSelect){
        Login login  = (Login) SecurityUtils.getSubject().getPrincipal(); //接收user类的所有属性
        Integer user_id=login.getUser_id();
        User  user=salesKitService.selectUser(user_id);
        return moneyCensusService.rankingReturnMoney(user,firstSelect,secondSelect);
    }

    //合同金额排行榜
    @RequestMapping(value = "/rankingcontractMoney" ,method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "合同金额排行榜",notes = "合同金额排行榜",
            httpMethod = "GET",
            response =ResultJson.class )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firstSelect",value = "第二个下拉框的选项：传给后端的值，写四个：nowDay,nowMonth,nowYear,2020-09-07--2020-09-08 默认值为nowDay",
                    paramType = "query",
                    dataType = "String",required =false),
            @ApiImplicitParam(name = "secondSelect",value = "第一个下拉框的选项，传给后端的值，三个：myself,myDepartment,all，默认值：myself",paramType = "query",
                    dataType = "String",required = false),
    })
    public ResultJson rankingcontractMoney(String firstSelect,String secondSelect){
        Login login  = (Login) SecurityUtils.getSubject().getPrincipal(); //接收user类的所有属性
        Integer user_id=login.getUser_id();
        User  user=salesKitService.selectUser(user_id);
        return  moneyCensusService.rankingcontractMoney(user,firstSelect,secondSelect);
    }

    //合同个数排行榜
    @RequestMapping(value = "/rankingcontractCountMoney" ,method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "合同个数排行榜",notes = "合同个数排行榜",
            httpMethod = "GET",
            response =ResultJson.class )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firstSelect",value = "第二个下拉框的选项：传给后端的值，写四个：nowDay,nowMonth,nowYear,2020-09-07--2020-09-08 默认值为nowDay",
                    paramType = "query",
                    dataType = "String",required =false),
            @ApiImplicitParam(name = "secondSelect",value = "第一个下拉框的选项，传给后端的值，三个：myself,myDepartment,all，默认值：myself",paramType = "query",
                    dataType = "String",required = false),
    })
    public ResultJson rankingcontractCountMoney(String firstSelect,String secondSelect){
        Login login  = (Login) SecurityUtils.getSubject().getPrincipal(); //接收user类的所有属性
        Integer user_id=login.getUser_id();
        User  user=salesKitService.selectUser(user_id);

//        User user=new User();
//        user.setId(3);
        return  moneyCensusService.rankingcontractCountMoney(user,firstSelect,secondSelect);
    }

    //新增客户数
    @RequestMapping(value = "/rankingnewaddCustomer" ,method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "新增客户数排行榜",notes = "新增客户数排行榜",
            httpMethod = "GET",
            response =ResultJson.class )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firstSelect",value = "第二个下拉框的选项：传给后端的值，写四个：nowDay,nowMonth,nowYear,2020-09-07--2020-09-08 默认值为nowDay",
                    paramType = "query",
                    dataType = "String",required =false),
            @ApiImplicitParam(name = "secondSelect",value = "第一个下拉框的选项，传给后端的值，三个：myself,myDepartment,all，默认值：myself",paramType = "query",
                    dataType = "String",required = false),
    })
    public ResultJson rankingnewaddCustomer(String firstSelect,String secondSelect){
        Login login  = (Login) SecurityUtils.getSubject().getPrincipal(); //接收user类的所有属性
        Integer user_id=login.getUser_id();
        User  user=salesKitService.selectUser(user_id);
        return  moneyCensusService.rankingnewaddCustomer(user,firstSelect,secondSelect);
    }

    //新增联系人
    @RequestMapping(value = "/rankingnewaddContacts" ,method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "新增联系人排行榜",notes = "新增联系人排行榜",
            httpMethod = "GET",
            response =ResultJson.class )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firstSelect",value = "第二个下拉框的选项：传给后端的值，写四个：nowDay,nowMonth,nowYear,2020-09-07--2020-09-08 默认值为nowDay",
                    paramType = "query",
                    dataType = "String",required =false),
            @ApiImplicitParam(name = "secondSelect",value = "第一个下拉框的选项，传给后端的值，三个：myself,myDepartment,all，默认值：myself",paramType = "query",
                    dataType = "String",required = false),
    })
    public ResultJson rankingnewaddContacts(String firstSelect,String secondSelect){
        Login login  = (Login) SecurityUtils.getSubject().getPrincipal(); //接收user类的所有属性
        Integer user_id=login.getUser_id();
        User  user=salesKitService.selectUser(user_id);
        return  moneyCensusService.rankingnewaddContacts(user,firstSelect,secondSelect);
    }

    //新增商机
    @RequestMapping(value = "/rankingnewaddOpportunity" ,method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "新增商机排行榜",notes = "新增商机排行榜",
            httpMethod = "GET",
            response =ResultJson.class )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firstSelect",value = "第二个下拉框的选项：传给后端的值，写四个：nowDay,nowMonth,nowYear,2020-09-07--2020-09-08 默认值为nowDay",
                    paramType = "query",
                    dataType = "String",required =false),
            @ApiImplicitParam(name = "secondSelect",value = "第一个下拉框的选项，传给后端的值，三个：myself,myDepartment,all，默认值：myself",paramType = "query",
                    dataType = "String",required = false),
    })
    public ResultJson rankingnewaddOpportunity(String firstSelect,String secondSelect){
        Login login  = (Login) SecurityUtils.getSubject().getPrincipal(); //接收user类的所有属性
        Integer user_id=login.getUser_id();
        User  user=salesKitService.selectUser(user_id);
        return  moneyCensusService.rankingnewaddOpportunity(user,firstSelect,secondSelect);
    }

    //新增商机金额
    @RequestMapping(value = "/rankingnewaddOpportunityMoney" ,method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "新增商机金额排行榜",notes = "新增商机金额排行榜",
            httpMethod = "GET",
            response =ResultJson.class )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firstSelect",value = "第二个下拉框的选项：传给后端的值，写四个：nowDay,nowMonth,nowYear,2020-09-07--2020-09-08 默认值为nowDay",
                    paramType = "query",
                    dataType = "String",required =false),
            @ApiImplicitParam(name = "secondSelect",value = "第一个下拉框的选项，传给后端的值，三个：myself,myDepartment,all，默认值：myself",paramType = "query",
                    dataType = "String",required = false),
    })
    public ResultJson rankingnewaddOpportunityMoney(String firstSelect,String secondSelect){
        Login login  = (Login) SecurityUtils.getSubject().getPrincipal(); //接收user类的所有属性
        Integer user_id=login.getUser_id();
        User  user=salesKitService.selectUser(user_id);
        return  moneyCensusService.rankingnewaddOpportunityMoney(user,firstSelect,secondSelect);
    }

    //新增跟进记录
    @RequestMapping(value = "/rankingnewaddFollow" ,method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "新增跟进记录排行榜",notes = "新增跟进记录排行榜",
            httpMethod = "GET",
            response =ResultJson.class )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "firstSelect",value = "第二个下拉框的选项：传给后端的值，写四个：nowDay,nowMonth,nowYear,2020-09-07--2020-09-08 默认值为nowDay",
                    paramType = "query",
                    dataType = "String",required =false),
            @ApiImplicitParam(name = "secondSelect",value = "第一个下拉框的选项，传给后端的值，三个：myself,myDepartment,all，默认值：myself",paramType = "query",
                    dataType = "String",required = false),
    })
    public ResultJson rankingnewaddFollow(String firstSelect,String secondSelect){
        Login login  = (Login) SecurityUtils.getSubject().getPrincipal(); //接收user类的所有属性
        Integer user_id=login.getUser_id();
        User  user=salesKitService.selectUser(user_id);
        return  moneyCensusService.rankingnewaddFollow(user,firstSelect,secondSelect);
    }





}
